import { lazy } from 'react'
import { createBrowserRouter, createHashRouter } from 'react-router-dom'
import App from '../views/App'
// import Fast from '../views/Fast'
// import Home from '../views/Home'
import Login from '../views/Login'
// import Mine from '../views/Mine'
// import Practice from '../views/Practice'
// import Subjects from '../views/Sbujects'
// import Select from '../views/Select'

// react里面实现路由的懒加载，需要使用 内置的一个函数 lazy
const Home = lazy(() => import('../views/Home'))
const Fast = lazy(() => import('../views/Fast'))
const Mine = lazy(() => import('../views/Mine'))
const Practice = lazy(() => import('../views/Practice'))
const Subjects = lazy(() => import('../views/Sbujects'))
const Select = lazy(() => import('../views/Select'))
// 还有第二步： 需要在 路由 懒加载的外面 加上 suspanse 组件

const router = createHashRouter([
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/',
        element: <App />,
        children: [
            {
                path: 'home',
                element: <Home />
            },
            {
                path: 'fast',
                element: <Fast />
            },
            {
                path: 'mine',
                element: <Mine />
            },
            {
                path: 'select/:actionCode',
                element: <Select />
            },
            {
                path: 'practice',
                element: <Practice />
            },
            {
                path: 'subjects',
                element: <Subjects />
            },
        ]
    }
])

export default router